<template>
  <basic-container>
    <el-container>
      <el-aside width="260px">
        <avue-tree :option="treeOption" :data="treeData" @node-click="treeNodeClick">
          <template slot-scope="scope" slot="addBtn">
          </template>
        </avue-tree>
      </el-aside>
      <el-main>
        <avue-crud :option="option"
                  :table-loading="loading"
                  :data="data"
                  ref="crud"
                  v-model="form"
                  :defaults.sync="showColumn"
                  :permission="permissionList"
                  :page.sync="page"
                  :before-open="beforeOpen"
                  @sortable-change="sortableChange"
                  @row-del="rowDel"
                  @row-update="rowUpdate"
                  @row-save="rowSave"
                  @refresh-change="refreshChange"
                  @search-change="searchChange"
                  @search-reset="searchReset"
                  @selection-change="selectionChange"
                  @current-change="currentChange"
                  @size-change="sizeChange"
                  @filter="filterChange"
                  @sort-change="sortChange"
                  @row-dblclick="handleRowDBLClick"               
                  @on-load="onLoad">
          <template slot-scope="scope" slot="menu">
          </template>
          <template slot-scope="scope" slot="userIdForm">
            <div>
              <el-tag v-if="form.status != '1'" type="info">否</el-tag>
              <el-tag v-if="form.status == '1'" type="success">是</el-tag>
            </div>
          </template>
          <template slot-scope="scope" slot="userId">
            <div>
              <el-tag v-if="scope.row.status != '1'" type="info">否</el-tag>
              <el-tag v-if="scope.row.status == '1'" type="success">是</el-tag>
            </div>
          </template>
          <template slot-scope="scope" slot="menuLeft">
            <el-button type="primary"
                      size="small"
                      icon="el-icon-plus"
                      v-if="permission.general_staff_batch_add"
                      @click.stop="openBatchAddDialog">批量新增
            </el-button>
            <el-button type="danger"
                      size="small"
                      icon="el-icon-delete"
                      v-if="permission.general_staff_batch_delete"
                      @click.stop="handleDelete">删 除
            </el-button>
          </template>
          <template slot-scope="scope" slot="menu">
            <el-button type="text"
                      size="small"
                      icon="el-icon-edit"
                      v-if="permission.general_project_s_edit  && scope.row.status !== '1'"
                      @click="createSysUser(scope.row)">创建用户
            </el-button>
            <el-button type="text"
                      size="small"
                      icon="el-icon-edit"
                      v-if="permission.general_project_s_edit  && scope.row.status == '1'"
                      @click="deleteSysUser(scope.row)">注销
            </el-button>
          </template>
          <template slot="menuRight">
            <el-button v-if="permission.general_staff_download" type="default" @click.stop="exportExcel"  title="下载" icon="el-icon-download" circle size="small"></el-button>
          </template>
        </avue-crud>
      </el-main>
    </el-container> 
    <!-- 
      批量添加数据对话框
     -->
    <el-dialog title="批量导入" width='80%' :close-on-click-modal='false' :visible.sync="batchAddDialog">
      <el-tag>
		员工ID，
		员工类型，
		员工姓名，
		头像链接，
		性别，
		出生日期，
		身份证号码，
		民族，
		籍贯，
		出生地址，
		政治面貌，
		婚姻状况，
		健康状况，
		毕业院校名称，
		学历名称，
		手机号码，
		邮箱地址，
		座机号码，<br>
		现居地址，
		语言信息，
		教育信息列表，
		专业技能列表，
		资质信息列表，
		获奖信息列表，
		社会关系列表，
		职务级别，
		职务名称，
		岗位名称，
		职称名称，
		机构号，
		机构名称，
		上级机构号，
		上级机构名称，<br>
		员工状态，
		入职日期，
		入职经办人，
		离职日期，
		离职经办人，
		离职原因，
		合同到期日期，
		合同链接，
		账号列表，
		办公地址，<br>
		通用标签，
		公司名称，
		参加工作日期，
		金融工作年限，
		核心项目个数，
		工作经历列表，
		项目经历列表，
		行内服务标志，
		行内项目列表，
		服务类型，<br>
		驻场类型，
		所属项目名称，
		级别名称，
		档次名称，
		入场日期，
		入场经办人，
		离场日期，
		离场经办人，
		离场原因，
      </el-tag>
      <el-input
        type="textarea"
        :autosize="{ minRows: 10, maxRows: 20}"
        placeholder="请直接从excel粘贴内容"
        v-model="importDataArea">
      </el-input>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" type="primary" id="copyBtn" @click="handleImport($event)" data-clipboard-target="#pathText">开始导入</el-button>
        <el-button size="small" @click="batchAddDialog = false">取 消</el-button>
      </div>
    </el-dialog>
  </basic-container>
</template>

<script>
import {updateSysUserInfo,saveSysUserInfo,restAdminPassword,querySysUserInfo} from '@/api/system/sysUserInfoApi';
import {queryGeneralOrgInfoListPage} from '@/api/general/staff/generalOrgInfoApi';
import {exportGeneralStaffInfoExcel,saveOrUpdateGeneralStaffInfo,saveOrUpdateGeneralStaffInfoList,saveGeneralStaffInfo,saveGeneralStaffInfoList,deleteGeneralStaffInfo,queryGeneralStaffInfo,queryGeneralStaffInfoListPage,updateGeneralStaffInfo,deleteGeneralStaffInfoList} from '@/api/general/staff/generalStaffInfoApi';
import {mapGetters} from 'vuex';
import { reqCommonMsg } from '@/util/reqCommonMsg';
import {filterFormat} from '@/util/util';
export default {
  data() {
    return {
      importDataArea: '',
      batchAddDialog: false,
      form: {},
      selectionList: [],
      loading: true, 
      showColumn: [],
      // 外包信息选项卡
      outsource: {
        label: '外包信息',
        prop: 'outsource',
        column: [
          {
            label: '公司名称',
            prop: 'companyName', 
            type: 'input', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 8,
            sortable: false,
            hide: true,
            overHidden: true,
            rules: [{
              required:  false,
              message: '请输入内容',
              trigger: 'blur'
            }],
            dicData:[]
          },
          {
            label: '参加工作日期',
            prop: 'joinJobDate', 
            type: 'input', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 8,
            sortable: false,
            hide: true,
            overHidden: true,
            rules: [{
              required:  false,
              message: '请输入内容',
              trigger: 'blur'
            }],
            dicData:[]
          },
          {
            label: '金融工作年限',
            prop: 'financeJobYears', 
            type: 'input', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 8,
            sortable: false,
            hide: true,
            overHidden: true,
            rules: [{
              required:  false,
              message: '请输入内容',
              trigger: 'blur'
            }],
            dicData:[]
          },
          {
            label: '核心项目个数',
            prop: 'coreProjectCount', 
            type: 'input', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 8,
            sortable: false,
            hide: true,
            overHidden: true,
            rules: [{
              required:  false,
              message: '请输入内容',
              trigger: 'blur'
            }],
            dicData:[]
          },
          {
            label: '工作经历列表',
            prop: 'jobExpeList', 
            type: 'input', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 8,
            sortable: false,
            hide: true,
            overHidden: true,
            rules: [{
              required:  false,
              message: '请输入内容',
              trigger: 'blur'
            }],
            dicData:[]
          },
          {
            label: '项目经历列表',
            prop: 'projectExpeList', 
            type: 'input', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 8,
            sortable: false,
            hide: true,
            overHidden: true,
            rules: [{
              required:  false,
              message: '请输入内容',
              trigger: 'blur'
            }],
            dicData:[]
          },
          {
            label: '行内服务标志',
            prop: 'ownBankServiceFlag', 
            type: 'input', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 8,
            sortable: false,
            hide: true,
            overHidden: true,
            rules: [{
              required:  false,
              message: '请输入内容',
              trigger: 'blur'
            }],
            dicData:[]
          },
          {
            label: '行内项目列表',
            prop: 'ownBankProjectList', 
            type: 'input', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 8,
            sortable: false,
            hide: true,
            overHidden: true,
            rules: [{
              required:  false,
              message: '请输入内容',
              trigger: 'blur'
            }],
            dicData:[]
          },
          {
            label: '服务类型',
            prop: 'serviceType', 
            type: 'input', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 8,
            sortable: false,
            hide: true,
            overHidden: true,
            rules: [{
              required:  false,
              message: '请输入内容',
              trigger: 'blur'
            }],
            dicData:[]
          },
          {
            label: '驻场类型',
            prop: 'settleType', 
            type: 'input', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 8,
            sortable: false,
            hide: true,
            overHidden: true,
            rules: [{
              required:  false,
              message: '请输入内容',
              trigger: 'blur'
            }],
            dicData:[]
          },
          {
            label: '所属项目名称',
            prop: 'belongProjectName', 
            type: 'input', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 8,
            sortable: false,
            hide: true,
            overHidden: true,
            rules: [{
              required:  false,
              message: '请输入内容',
              trigger: 'blur'
            }],
            dicData:[]
          },
          {
            label: '级别名称',
            prop: 'levelName', 
            type: 'input', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 8,
            sortable: false,
            hide: true,
            overHidden: true,
            rules: [{
              required:  false,
              message: '请输入内容',
              trigger: 'blur'
            }],
            dicData:[]
          },
          {
            label: '档次名称',
            prop: 'gradeName', 
            type: 'input', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 8,
            sortable: false,
            hide: true,
            overHidden: true,
            rules: [{
              required:  false,
              message: '请输入内容',
              trigger: 'blur'
            }],
            dicData:[]
          },
          {
            label: '入场日期',
            prop: 'entranceDate', 
            type: 'input', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 8,
            sortable: false,
            hide: true,
            overHidden: true,
            rules: [{
              required:  false,
              message: '请输入内容',
              trigger: 'blur'
            }],
            dicData:[]
          },
          {
            label: '入场经办人',
            prop: 'entranceOptName', 
            type: 'input', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 8,
            sortable: false,
            hide: true,
            overHidden: true,
            rules: [{
              required:  false,
              message: '请输入内容',
              trigger: 'blur'
            }],
            dicData:[]
          },
          {
            label: '离场日期',
            prop: 'departureDate', 
            type: 'input', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 8,
            sortable: false,
            hide: true,
            overHidden: true,
            rules: [{
              required:  false,
              message: '请输入内容',
              trigger: 'blur'
            }],
            dicData:[]
          },
          {
            label: '离场经办人',
            prop: 'departureOptName', 
            type: 'input', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 8,
            sortable: false,
            hide: true,
            overHidden: true,
            rules: [{
              required:  false,
              message: '请输入内容',
              trigger: 'blur'
            }],
            dicData:[]
          },
          {
            label: '离场原因',
            prop: 'departureReason', 
            type: 'input', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 8,
            sortable: false,
            hide: true,
            overHidden: true,
            rules: [{
              required:  false,
              message: '请输入内容',
              trigger: 'blur'
            }],
            dicData:[]
          },
        ]
      },
      option: {
        labelPosition: 'right',
        labelSuffix: '：',
        labelWidth: 120,
        dialogTop: '50',
        indexFixed:true, 
        stripe:true,
        calcHeight: 80,
        searchShow: true,
        searchMenuSpan: 6,
        tip: false,
        border: true,
        index: true,
        selection: true,
        addBtn: true,
        viewBtn: false,
        delBtn: false,
        cancelBtn: true,
        printBtn:false,
        saveBtn: true,
        filterBtn:true,          
        menuWidth: 200,
        dialogMenuPosition: 'center',
        dialogDirection:'rtl',
        dialogType:'dialog',
        dialogFullscreen:false,
        dialogClickModal:false,
        dialogWidth: '70%',
        highlightCurrentRow:  true,
        searchShow:true,
        sortable: true,
        column: [
          {
            label: '员工类型',
            prop: 'staffType', 
            type: 'select', 
            search: true,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            sortable: false,
            hide: false,
            overHidden: true,
            display: false,
            rules: [{
              required:  true,
              message: '请输入内容',
              trigger: 'blur'
            }],
            dicData: [{
              label: '自有人员',
              value: '自有人员'
            }, 
            {
              label: '借调人员',
              value: '借调人员'
            }, 
            {
              label: '外包人员',
              value: '外包人员'
            }, 
            {
              label: '特聘人员',
              value: '特聘人员'
            }, 
            {
              label: '临时人员',
              value: '临时人员'
            }, 
            {
              label: '实习人员',
              value: '实习人员'
            },
            {
              label: '见习人员',
              value: '见习人员'
            }
            ]
          },
          {
            label: '员工号',
            prop: 'staffId', 
            type: 'input', 
            search: true,
            searchMmultiple: true,
            searchLabelWidth: 100,
            multiple: false,
            span: 8,
            sortable: false,
            hide: false,
            display: false,
            overHidden: true,
            rules: [{
              required:  true,
              message: '请输入内容',
              trigger: 'blur'
            }],
            dicData:[]
          },
          {
            label: '员工姓名',
            prop: 'staffName', 
            type: 'input', 
            search: true,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            sortable: false,
            hide: false,
            overHidden: true,
            display: false,
            rules: [{
              required:  true,
              message: '请输入内容',
              trigger: 'blur'
            }],
            dicData:[]
          },
          {
            label: '性别',
            prop: 'sex', 
            type: 'select', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 8,
            sortable: false,
            hide: true,
            overHidden: true,
            display: false,
            rules: [{
              required:  true,
              message: '请输入内容',
              trigger: 'blur'
            }],
            dicData: [{
              label: '男',
              value: '男'
            }, 
            {
              label: '女',
              value: '女'
            }, 
            ]
          },
          {
            label: '手机号码',
            prop: 'mobileNo', 
            type: 'input', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            sortable: false,
            hide: false,
            overHidden: true,
            display: false,
            rules: [
              {
                required:  true,
                message: '请输入内容',
                trigger: 'blur'
              },
              {
                // 检查手机号
                validator: (rule, value, callback) => {
                  if(value != '' && !this.$validate.isMobile(value)){
                    callback(new Error('请输入11位手机号码！'));
                  }
                  else{
                    callback();
                  }
                }
              }
            ],
            dicData:[]
          },
          {
            label: '头像链接',
            prop: 'headImgUrl', 
            type: 'input', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            sortable: false,
            hide: false,
            overHidden: true,
            display: false,
            rules: [{
              required:  false,
              message: '请输入内容',
              trigger: 'blur'
            }],
            dicData:[]
          },
          {
            label: '用户标识',
            prop: 'userId', 
            type: 'input', 
            hide: false,
            slot: true,
            formslot: true,
            display: false,
            rules: [{
              required:  true,
              message: '请输入内容',
              trigger: 'blur'
            }],
            dicData:[]
          }
        ],
        tabs: true,
        menuBtn: true,
        tabsActive:1,
        group: [
          {
            label: '基本信息',
            prop: 'basicInfo',
            column: [
              {
                label: '员工ID',
                prop: 'staffId', 
                type: 'input', 
                
                searchMmultiple: true,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: false,
                overHidden: true,
                rules: [{
                  required:  true,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
              
              {
                label: '员工姓名',
                prop: 'staffName', 
                type: 'input', 
                
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: false,
                overHidden: true,
                rules: [{
                  required:  true,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
              {
                label: '头像链接',
                prop: 'headImgUrl', 
                type: 'upload', 
                listType: 'picture-img',
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: false,
                overHidden: true,
                rules: [{
                  required:  false,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
              {
                label: '员工类型',
                prop: 'staffType', 
                type: 'select', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: false,
                overHidden: true,
                value: '自有人员',
                rules: [{
                  required:  true,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData: [{
                  label: '自有人员',
                  value: '自有人员'
                }, 
                {
                  label: '借调人员',
                  value: '借调人员'
                }, 
                {
                  label: '外包人员',
                  value: '外包人员'
                }, 
                {
                  label: '特聘人员',
                  value: '特聘人员'
                }, 
                {
                  label: '临时人员',
                  value: '临时人员'
                }, 
                {
                  label: '实习人员',
                  value: '实习人员'
                },
                {
                  label: '见习人员',
                  value: '见习人员'
                }
                ]
              },
              
              {
                label: '性别',
                prop: 'sex', 
                type: 'select', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  true,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                value: '男',
                dicData: [{
                  label: '男',
                  value: '男'
                }, 
                {
                  label: '女',
                  value: '女'
                }, 
                ]
              },
              {
                label: '出生日期',
                prop: 'birthDate', 
                type: 'date', 
                format:'yyyy-MM-dd',
                valueFormat: 'yyyy-MM-dd',
                pickerOptions: {
                  disabledDate(time) {
                    return time.getTime() > Date.now();
                  }
                },
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  true,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
              {
                label: '身份证号码',
                prop: 'idCardNo', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [
                  {
                    required:  true,
                    message: '请输入内容',
                    trigger: 'blur'
                  },
                  {
                    // 检查身份证号
                    validator: (rule, value, callback) => {
                      let result = this.$validate.IdentityCodeValid(value);
                      //this.$console.log('result===>', result);
                      if(!result){
                        callback(new Error('证件号码格式错误'));
                      }
                      else{
                        callback();
                      }
                    }
                  }
                ],
                dicData:[]
              },
              {
                label: '民族',
                prop: 'nation', 
                type: 'select', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  true,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                value: '汉族',
                dicData: [{
                  label: '汉族',
                  value: '汉族'
                }, 
                {
                  label: '蒙古族',
                  value: '蒙古族'
                }, 
                {
                  label: '回族',
                  value: '回族'
                }, 
                {
                  label: '藏族',
                  value: '藏族'
                }]
              },
              {
                label: '籍贯',
                prop: 'nativePlace', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  true,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
              {
                label: '出生地址',
                prop: 'birthAddress', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 24,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  true,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
              {
                label: '现居地址',
                prop: 'liveAddress', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 24,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  true,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
              {
                label: '政治面貌',
                prop: 'politicalPoliticalStatus', 
                type: 'select', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  true,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                value: '党员',
                dicData: [{
                  label: '党员',
                  value: '党员'
                }, 
                {
                  label: '预备党员',
                  value: '预备党员'
                },
                {
                  label: '团员',
                  value: '团员'
                },
                {
                  label: '民进',
                  value: '民进'
                }, 
                {
                  label: '民建',
                  value: '民建'
                },
                {
                  label: '农工党',
                  value: '农工党'
                },
                ]
              },
              {
                label: '婚姻状况',
                prop: 'marriageCond', 
                type: 'select', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  true,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                value: '未婚',
                dicData: [{
                  label: '未婚',
                  value: '未婚'
                }, 
                {
                  label: '已婚',
                  value: '已婚'
                },
                {
                  label: '离异',
                  value: '离异'
                },
                {
                  label: '丧偶',
                  value: '丧偶'
                }]
              },
              {
                label: '健康状况',
                prop: 'healthyCond', 
                type: 'select', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                value:'良好',
                rules: [{
                  required:  true,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData: [{
                  label: '健康',
                  value: '健康'
                }, 
                {
                  label: '良好',
                  value: '良好'
                },
                {
                  label: '一般',
                  value: '一般'
                },
                {
                  label: '较差',
                  value: '较差'
                },
                {
                  label: '疾病',
                  value: '疾病'
                },
                {
                  label: '残疾',
                  value: '残疾'
                }
                ]
              },
              {
                label: '邮箱地址',
                prop: 'emailAddress', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: false,
                overHidden: true,
                rules: [
                  {
                    required:  true,
                    message: '请输入内容',
                    trigger: 'blur'
                  },
                  {
                    validator: (rule, value, callback) => {
                      if(value != '' && !this.$validate.isEmail(value)){
                        callback(new Error('请输入正确的邮件地址！'));
                      }
                      else{
                        callback();
                      }
                    },
                  }
                ],
                dicData:[]
              },
              {
                label: '手机号码',
                prop: 'mobileNo', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: false,
                overHidden: true,
                rules: [
                  {
                    required:  true,
                    message: '请输入内容',
                    trigger: 'blur'
                  },
                  {
                    // 检查手机号
                    validator: (rule, value, callback) => {
                      if(value != '' && !this.$validate.isMobile(value)){
                        callback(new Error('请输入11位手机号码！'));
                      }
                      else{
                        callback();
                      }
                    }
                  }
                ],
                dicData:[]
              },
              {
                label: '毕业院校名称',
                prop: 'graduationCollegeName', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  false,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
              {
                label: '学历名称',
                prop: 'eduDegreeName', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  false,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
              {
                label: '座机号码',
                prop: 'telNo', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  false,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
              
              {
                label: '语言信息',
                prop: 'lanInfo', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  false,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
              {
                label: '所属机构',
                prop: 'belongOrgNo', 
                type: 'tree', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 24,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  true,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                props: {
                  label: 'orgName',
                  value: 'orgNo'
                },
                change: (data) => {
                  //this.$console.log(data)
                },
                dicData:[]
              }
            ]
          },
          {
            icon:'el-icon-info',  
            label: '教育&社会',
            prop: 'education',
            column: [
              {
                label: '教育信息列表',
                prop: 'educationEntity', 
                type: 'dynamic', 
                span:24,
                children: {
                  align: 'center',
                  headerAlign: 'center', 
                  column: [
                    {
                      width: 200,
                      label: '教育阶段',
                      prop: 'eduStage',
                      type: 'select',
                      value: '大学',
                      rules:[{
                        required:  true,
                        message: '请输入内容',
                      }],
                      dicData: [{
                        label: '大学',
                        value: '大学'
                      }, 
                      {
                        label: '高中',
                        value: '高中'
                      }, 
                      {
                        label: '初中',
                        value: '初中'
                      }]
                    }, 
                    {
                      label: '毕业学校',
                      prop: 'graduationSchool',
                      type: 'input',
                      rules:[{
                        required:  true,
                        message: '请输入内容',
                      }],
                    }, 
                    {
                      label: '毕业日期',
                      prop: 'graduationDate',
                      type: 'date',  
                      format: 'yyyy-MM-dd',
                      pickerOptions: {
                        disabledDate(time) {
                          return time.getTime() > Date.now();
                        }
                      },
                      rules:[{
                        required:  true,
                        message: '请输入内容',
                      }],
                    }, 
                    {
                      label: '学历',
                      prop: 'eduDegreeName',
                      type: 'select',
                      value: '本科',
                      rules:[{
                        require: false,
                        message:'请选择选择框',
                      }],
                      dicData: [{
                        label: '本科',
                        value: '本科'
                      }, 
                      {
                        label: '专科',
                        value: '专科'
                      }, 
                      {
                        label: '研究生',
                        value: '研究生'
                      }, 
                      {
                        label: '博士',
                        value: '博士'
                      }]
                    }
                  ]
                }
              },
              {
                label: '专业技能列表',
                prop: 'majorSkillList', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  false,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
              {
                label: '资质信息列表',
                prop: 'qualInfoList', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  false,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
              {
                label: '获奖信息列表',
                prop: 'awardInfoList', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  false,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
              {
                label: '社会关系列表',
                prop: 'societyRelationList', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  false,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
            ]
          },
          {
            label: '工作信息',
            prop: 'workInfo',
            column: [
              {
                label: '职务级别',
                prop: 'dutyGrade', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  false,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
              {
                label: '职务名称',
                prop: 'dutyName', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  false,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
              {
                label: '岗位名称',
                prop: 'stationName', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  false,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
              {
                label: '职称名称',
                prop: 'techTitleName', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  false,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
              {
                label: '员工状态',
                prop: 'staffStatus', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  false,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
              {
                label: '入职日期',
                prop: 'entryDate', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  false,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
              {
                label: '入职经办人',
                prop: 'entryOptName', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  false,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
              {
                label: '离职日期',
                prop: 'leaveDate', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  false,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
              {
                label: '离职经办人',
                prop: 'leaveOptName', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  false,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
              {
                label: '离职原因',
                prop: 'leaveReason', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  false,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
              {
                label: '合同到期日期',
                prop: 'agreementExpireDate', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  false,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
              {
                label: '合同链接',
                prop: 'agreementUrl', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  false,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
              {
                label: '账号列表',
                prop: 'acctList', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  false,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
              {
                label: '办公地址',
                prop: 'officeAddress', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  false,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
              {
                label: '通用标签',
                prop: 'generalLabel', 
                type: 'input', 
                search: false,
                searchMmultiple: false,
                searchLabelWidth: 100,
                multiple: false,
                span: 8,
                sortable: false,
                hide: true,
                overHidden: true,
                rules: [{
                  required:  false,
                  message: '请输入内容',
                  trigger: 'blur'
                }],
                dicData:[]
              },
            ]
          },
        ]
      },
      data: [],
      // 组织机构树形区
      checkedNode: '',
      currentOrgNo: '',
      orgType: '1',
      orgData: [],
      treeData:[],
      treeOption:{
        addBtn: false,
        menu: false,
        defaultExpandAll:false,
        formOption:{},
        lazy: true,
        treeLoad: (node, resolve) => {
          this.singleBody = {
            parentOrgNo: node.data.orgNo
          } 
          if (node.level === 0) {
            this.singleBody = {
              parentOrgNo: this.website.orgNo.genTreeOrgNo,
              orgType: '1'
            }
          }
          this.reqParams =  { 
            singleBody: this.singleBody,
            listBody: [],  
            extBody: {},  
            sqlCondition: [],  
            orderRule: [{prop:'order_seq',order:'ascending'}],
            currentPage: 0,
            pageSize: 99999,
            total: 100 
          }
          this.commonData = reqCommonMsg(this.reqParams)
          queryGeneralOrgInfoListPage(this.commonData).then(res => {
            let data = res.data.body.listBody;
            this.orgData = data;
            //this.$console.log('data=====>', data)
            data.forEach(element => {
              if(!element.hasChildren){
                element.leaf = true
              }
            });
            return resolve(data)
          }, error => {});
        },
        props: {
          label: 'orgName',
          value: 'orgNo'
        },
      },
      // 请求参数区
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0
      },
      reqParams: {
        chainnelId: 'PC',
        transCode: '0001',
        singleBody: {},
        listBody: [{}],
        sqlCondition:[],
        orderRule: {},
        currentPage: 1,
        pageSize: 10
      },
      commonData: null,
      conditions: [],
      orderRules: [],
      singleBody: {}
    };
  },
  computed: {
    ...mapGetters(['website','userInfo','orgTree','permission','genOrgTree']),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permission.general_staff_add, false),
        viewBtn: this.vaildData(this.permission.general_staff_view, false),
        delBtn: this.vaildData(this.permission.general_staff_delete, false),
        editBtn: this.vaildData(this.permission.general_staff_edit, false),
        printBtn: this.vaildData(this.permission.general_staff_print, false),
        searchBtn:this.vaildData(this.permission.general_staff_search, false)
      };
    },
    ids() {
      let ids = [];
      this.selectionList.forEach(ele => {
        ids.push({id : ele.id});
      });
      return ids;
    } 
  },
  methods: { 
    /**
     * 注销用户-逻辑置为不可用
     */
    deleteSysUser(row){
      this.$confirm('确定注销用户?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.updateUserInfo(row,'0');
      }).catch(() => {});  
    },
    /**
     * 创建系统用户
     */
    createSysUser(row){
      this.$confirm('确定创建用户?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        //创建记录
        if(!row.userId){
          this.addUserInfo(row);
        }
        //直接修改有效标志
        else{
          this.updateUserInfo(row,'1');
        }
      }).catch(() => {});  
      
      //this.$console.log("row = ",row ,loading)
    },
    /**
     * 添加用户记录
     */
    addUserInfo(row){
      let reqParams = {
        singleBody: {
          userName:row.staffId,
          realName:row.staffName,
          userType: 1,
          belongOrgNo: this.userInfo.belongOrgNo,
          belongOrgName: this.userInfo.belongOrgName,
          mobileNo: row.mobileNo,
          validFlag: '1'
        }
      };
      reqParams.singleBody.password = this.$toolUtil.encodeMd5(this.userInfo.tenantId);
      let commonData = reqCommonMsg(reqParams)
      saveSysUserInfo(commonData).then(() => {
        this.singleBody={};
        this.onLoad(this.page);
        this.$message({
          customClass:'zZindex',
          type: 'success',
          message: '操作成功!'
        });
      }, error => {
        //this.$console.log(error);
      });         
    },
    /**
     * 修改用户记录
     */
    updateUserInfo(row,validFlag){
      //先查询用户信息
      this.reqParams.singleBody.id = row.userId;
      let commonData = reqCommonMsg(this.reqParams)
      querySysUserInfo(commonData).then(res => {
        this.reqParams.singleBody = res.data.body.singleBody;
        this.reqParams.singleBody.validFlag = validFlag;
        this.commonData = reqCommonMsg(this.reqParams);
        // 修改记录
        updateSysUserInfo(this.commonData).then(() => {
          this.singleBody={}
          this.onLoad(this.page);
          this.$message({
            customClass:'zZindex',
            type: 'success',
            message: '操作成功!'
          });
        }, error => {
          //this.$console.log(error);
        });
      }); 
    },
    /**
     * 机构树形菜单点击时触发事件
     */
    treeNodeClick(data){
      this.currentOrgNo =  data.orgNo;
      this.onLoad(this.page)
    },
    /**
     * 加载列表数据
     */
    onLoad(page) {
      this.singleBody.belongOrgNo=this.currentOrgNo 
      this.loading = true;
      this.reqParams =  {
        singleBody: this.singleBody,
        listBody: [{}],
        sqlCondition: this.conditions,
        orderRule: this.orderRules,
        currentPage: page.currentPage, 
        pageSize: page.pageSize
      }
      this.commonData = reqCommonMsg(this.reqParams)
      queryGeneralStaffInfoListPage(this.commonData).then(res => {
        // 
        const data = res.data.body;
        this.page.total = data.total;
        this.data = data.listBody;
        this.loading = false;
        this.selectionClear();
      }, error => {
        this.loading = false; 
      });
    },
    /**
     * 新增一条记录
     */
    rowSave(row, done, loading) {
      this.reqParams.singleBody = row;
      // 处理所属机构名称
      for(let org of this.orgData){
        if(org.orgNo === row.belongOrgNo){
          this.reqParams.singleBody.belongOrgName = org.orgName;
          break;
        }
      }
      this.commonData = reqCommonMsg(this.reqParams)
      saveGeneralStaffInfo(this.commonData).then(() => {
        done();
        this.singleBody={};
        this.onLoad(this.page);
        this.$message({
          customClass:'zZindex',
          type: 'success',
          message: '操作成功!'
        });
      }, error => {
        //this.$console.log(error);
        loading();
      });         
      //this.$console.log('row = ',row ,loading)
    },
    /**
     * 修改一条记录
     */
    rowUpdate(row, index, done, loading) { 
      this.reqParams.singleBody = row;
      this.commonData = reqCommonMsg(this.reqParams)
      updateGeneralStaffInfo(this.commonData).then(() => {
        done();
        this.singleBody={}
        this.onLoad(this.page);
        this.$message({
          customClass:'zZindex',
          type: 'success',
          message: '操作成功!'
        });
      }, error => {
        //this.$console.log(error);
        loading();
      });
      //this.$console.log('loading = ',loading)
    },
    /**
     * 删除一条记录
     */
    rowDel(row) {
      this.$confirm('确定将选择数据删除?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.reqParams.singleBody = row;
          this.commonData = reqCommonMsg(this.reqParams);
          return deleteGeneralStaffInfo(this.commonData);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            customClass:'zZindex',
            type: 'success',
            message: '操作成功!'
          });
        }).catch(() => {});
    },
    /**
     * 双击打开详细窗口
     */
    handleRowDBLClick (row, event) {
      if(this.permission.general_staff_dbclick){
        this.$refs.crud.rowView(row,row.$index);
      }
    },
    /**
     * 批量新增记录
     */
    openBatchAddDialog(){
      this.batchAddDialog = true;
    },
    // 
    handleImport() {
      this.loading=true;
      var dataList = new Array();
      if(this.importDataArea){
        var lineList = this.importDataArea.split('\n')
        lineList.forEach((element,index) => {
          if(element.trim() != ''){
            var field = element.split('\t')
            var fieldList = {
              staffId:field[0].trim(),
              staffType:field[1].trim(),
              staffName:field[2].trim(),
              headImgUrl:field[3].trim(),
              sex:field[4].trim(),
              birthDate:field[5].trim(),
              idCardNo:field[6].trim(),
              nation:field[7].trim(),
              nativePlace:field[8].trim(),
              birthAddress:field[9].trim(),
              politicalPoliticalStatus:field[10].trim(),
              marriageCond:field[11].trim(),
              healthyCond:field[12].trim(),
              graduationCollegeName:field[13].trim(),
              eduDegreeName:field[14].trim(),
              mobileNo:field[15].trim(),
              emailAddress:field[16].trim(),
              telNo:field[17].trim(),
              liveAddress:field[18].trim(),
              lanInfo:field[19].trim(),
              eduInfoList:field[20].trim(),
              majorSkillList:field[21].trim(),
              qualInfoList:field[22].trim(),
              awardInfoList:field[23].trim(),
              societyRelationList:field[24].trim(),
              dutyGrade:field[25].trim(),
              dutyName:field[26].trim(),
              stationName:field[27].trim(),
              techTitleName:field[28].trim(),
              belongOrgNo:field[29].trim(),
              belongOrgName:field[30].trim(),
              parentOrgNo:field[31].trim(),
              parentOrgName:field[32].trim(),
              staffStatus:field[33].trim(),
              entryDate:field[34].trim(),
              entryOptName:field[35].trim(),
              leaveDate:field[36].trim(),
              leaveOptName:field[37].trim(),
              leaveReason:field[38].trim(),
              agreementExpireDate:field[39].trim(),
              agreementUrl:field[40].trim(),
              acctList:field[41].trim(),
              officeAddress:field[42].trim(),
              generalLabel:field[43].trim(),
              companyName:field[44].trim(),
              joinJobDate:field[45].trim(),
              financeJobYears:field[46].trim(),
              coreProjectCount:field[47].trim(),
              jobExpeList:field[48].trim(),
              projectExpeList:field[49].trim(),
              ownBankServiceFlag:field[50].trim(),
              ownBankProjectList:field[51].trim(),
              serviceType:field[52].trim(),
              settleType:field[53].trim(),
              belongProjectName:field[54].trim(),
              levelName:field[55].trim(),
              gradeName:field[56].trim(),
              entranceDate:field[57].trim(),
              entranceOptName:field[58].trim(),
              departureDate:field[59].trim(),
              departureOptName:field[60].trim(),
              departureReason:field[61].trim(),
            }
            dataList[index] = fieldList
            //this.$console.log('fieldList = ',fieldList)
          }
        });
        //批量写入记录
        this.reqParams.listBody = dataList;
        this.commonData = reqCommonMsg(this.reqParams)
        saveGeneralStaffInfoList(this.commonData).then(() => {
          this.loading=false;
          this.onLoad(this.page);
          this.$message({
            customClass:'zZindex',
            type: 'success',
            message: '操作成功!'
          });
        }, error => {
          //this.$console.log(error);
          this.loading=false;
          loading();
        });      
        //this.$console.log('lineList=',dataList)
      }
      else{
        this.loading=false;
        this.$message({
          customClass:'zZindex',
          type: 'warning',
          message: '数据格式不正确!'
        });
      }
    },
    /**
     * 搜索重置
     */
    searchReset() {
      this.conditions =[];
      this.singleBody = {};
      this.onLoad(this.page);
    },
    /**
     * 搜索
     */
    searchChange(params, done) {
      this.singleBody = params
      this.page.currentPage = 1;
      this.onLoad(this.page);
      done();
    },
    refreshChange(){
      this.onLoad(this.page);
    },
    selectionChange(list) {
      this.selectionList = list;
    },
    selectionClear() {
      this.selectionList = [];
      this.$refs.crud.toggleSelection();
    },
    /**
     * 处理批量删除
     */
    handleDelete() {
      if (this.selectionList.length === 0) {
        this.$message.warning('请选择至少一条数据');
        return;
      }
      this.$confirm('确定将选择数据删除?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.reqParams.listBody = this.ids;
          this.commonData = reqCommonMsg(this.reqParams);
          return deleteGeneralStaffInfoList(this.commonData);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            customClass:'zZindex',
            type: 'success',
            message: '操作成功!'
          });
          this.$refs.crud.toggleSelection();
        }).catch(() => {});
    },
    /**
     * 拷贝记录
     */
    handleCopy(row){
      this.$confirm('确定复制数据?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.loading=true;
        let copyValue=row;
        copyValue.id='0';
        copyValue.dataSign='0'
        copyValue.tableName='拷贝 '+ copyValue.tableName; 
        this.reqParams.singleBody = copyValue;
        this.commonData = reqCommonMsg(this.reqParams)
        saveSysToolTables(this.commonData).then(() => {
          this.singleBody={};
          this.onLoad(this.page);
          this.$message({
            customClass:'zZindex',
            type: 'success',
            message: '操作成功!'
          });
          this.loading=false;
        }, error => {
          //this.$console.log(error);
          this.loading=false;
        });
      }).catch(() => {});       
    },
    /**
     * 打开编辑、查询弹窗前查询记录
     */  
    beforeOpen(done, type) {
      this.reqParams =  {
        chainnelId: 'PC',
        transCode: '0001',
        singleBody: {
          id:this.form.id
        }
      }
      let commonData = reqCommonMsg(this.reqParams)
      if (['edit', 'view'].includes(type)) {
        queryGeneralStaffInfo(commonData).then(res => {
          this.form = res.data.body.singleBody;
        });
      }
      //注意：不能放在mounted里，或出现加载不成功
      this.getOrgTree();
      done();
    },
    /**
     * 翻页查询
     */
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    /**
     * 更改每页条数
     */
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    /**
     * 自定义查询条件
     */
    filterChange(result) {
      this.page.currentPage = 1;
      this.conditions = filterFormat(result)
      this.onLoad(this.page);
    },
    /**
     * 列表排序
     */
    sortChange(val){
      this.orderRules=val
      this.onLoad(this.page);
    },
  
    /**
     * 导出Excel
     */
    exportExcel() {
      this.reqParams =  {
        chainnelId: 'PC',
        transCode: '0001',
        singleBody: this.singleBody,
        listBody: [{}],
        sqlCondition: this.conditions,
        orderRule: this.orderRules,
        currentPage:1, 
        pageSize: 100
      }
      //this.$console.log('reqParams = ',this.reqParams)
      this.commonData = reqCommonMsg(this.reqParams)
      exportGeneralStaffInfoExcel(this.commonData);
    },
    /**
     * 获取树形菜单
     */
    getOrgTree(){
      const column = this.findObject(this.option.group[0].column, 'belongOrgNo');
      this.genOrgTree.forEach((element,index) => {
        if(element.orgType == '1'){
          //this.$console.log('element == ',element);
          column.dicData = [element];
        }
      });
    },
  },
  created() {
    this.showColumn = this.$getStore({name:  this.userInfo.userId +'generalStaffInfoColumn'});
  },
  watch: {
    showColumn: {
      handler(newValue, oldValue) {
        this.$setStore({name:  this.userInfo.userId+'generalStaffInfoColumn', content: this.showColumn});
      },
      deep: true
      //this.$setStore({name: this.userInfo.userId +'generalStaffInfoColumn', content: this.showColumn});
    },
    'form.staffType':{
      handler(val){
        var staffType =this.findObject(this.option.column, 'staffType')
        if(val === '外包人员'){
          this.option.group.push(this.outsource);
        }else{
          var index = this.option.group.indexOf(this.outsource);
          if (index > -1) {
            this.option.group.splice(index, 1);
          }
        }
      },
      immediate: true
    }
  }
};
</script>
<style>
.el-main {
    margin-left: 5px !important;  
    border-left: 10px solid #f3f3f3 !important;  
}
</style>
